package com.suke.czx.modules.sys.entity;

import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.suke.czx.common.validate.EnumValue;
import com.suke.czx.common.validate.SysMenuSaveGroup;
import com.suke.czx.common.validate.SysUserSaveGroup;
import com.suke.czx.common.validate.SysUserUpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * 应用模块名称: 系统用户
 * 代码描述: 用户实体
 * copyright: AUZAR ALL RIGHTS RESERVED
 * company: AUZAR
 *
 * @author: 颜米晨
 * @date: 2021/08/27 16:31
 */
@Data
@ApiModel(value = "系统用户")
@EqualsAndHashCode(callSuper = true)
public class SysUser extends Model<SysUser> {

	@ApiModelProperty(value = "用户id")
	@TableId(value = "user_id", type = IdType.AUTO)
	@NotNull(groups = {SysUserUpdateGroup.class}, message = "用户编码不能为空")
	public Long userId;

	@ApiModelProperty(value = "用户名")
	@NotBlank(groups = {SysUserSaveGroup.class}, message = "用户名不能为空")
	public String username;

	@ApiModelProperty(value = "密码")
	@NotBlank(groups = {SysUserSaveGroup.class}, message = "密码不能为空")
	public String password;

	@ApiModelProperty(value = "姓名")
	@NotBlank(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "姓名不能为空")
	public String name;

	@ApiModelProperty(value = "邮箱")
	public String email;

	@ApiModelProperty(value = "手机号")
	@NotBlank(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "手机号不能为空")
	public String mobile;

	@ApiModelProperty(value = "身份证")
	@NotBlank(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "身份证不能为空")
	public String idCard;

	@ApiModelProperty(value = "出生日期")
	@NotNull(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "出生日期不能为空")
	@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
	public Date birthDate;

	@ApiModelProperty(value = "性别 0：男 1：女")
	@NotNull(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "性别不能为空")
	@EnumValue(groups = {SysMenuSaveGroup.class, SysUserUpdateGroup.class}, intValues = {0, 1}, message = "性别只能是0,1")
	public Integer sex;

	@ApiModelProperty(value = "岗位")
	@NotBlank(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "岗位不能为空")
	public String jobs;

	@ApiModelProperty(value = "部门")
	@NotBlank(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "部门不能为空")
	public String department;

	@ApiModelProperty(value = "喜好")
	public String hobbies;

	@ApiModelProperty(value = "紧急联系人")
	public String emergencyContact;

	@ApiModelProperty(value = "紧急联系人方式")
	public String emergencyContactWay;

	@ApiModelProperty(value = "配偶姓名")
	public String spouseName;

	@ApiModelProperty(value = "配偶联系方式")
	public String spouseContactWay;

	@ApiModelProperty(value = "父亲姓名")
	public String fatherName;

	@ApiModelProperty(value = "父亲联系方式")
	public String fatherContactWay;

	@ApiModelProperty(value = "母亲姓名")
	public String motherName;

	@ApiModelProperty(value = "母亲联系方式")
	public String motherContactWay;

	@ApiModelProperty(value = "入职日期")
	@NotNull(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "入职日期不能为空")
	@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
	public Date entryDate;

	@ApiModelProperty(value = "离职日期")
	public String departureDate;

	@ApiModelProperty(value = "工作状态 1：实习  2：试用  3：在职  4：离职")
	@NotNull(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "工作状态不能为空")
	@EnumValue(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, intValues = {1, 2, 3, 4}, message = "工作状态状态只能是1,2,3,4")
	public Integer workStatus;

	@ApiModelProperty(value = "离职意愿")
	public String departureDesire;

	@ApiModelProperty(value = "去向")
	public String whereabouts;

	@ApiModelProperty(value = "毕业院校")
	public String graduateSchool;

	@ApiModelProperty(value = "毕业时间")
	@DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
	public Date graduateDate;

	@ApiModelProperty(value = "专业技能")
	public String profession;

	@ApiModelProperty(value = "员工等级")
	@NotNull(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "员工等级不能为空")
	@EnumValue(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, strValues = {"A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9"},
			message = "工作状态状态只能是A1,A2,A3,A4,A5,A6,A7,A8,A9")
	public String grade;

	@ApiModelProperty(value = "备注")
	public String note;

	@ApiModelProperty(value = "状态  0：禁用   1：正常")
	@EnumValue(groups = {SysUserUpdateGroup.class}, intValues = {0, 1}, message = "用户状态只能是0,1")
	public Integer status;

	@ApiModelProperty(value = "创建者id")
	public Long creator;

	@ApiModelProperty(value = "创建时间")
	public Date createTime;

	@ApiModelProperty(value = "更新者id")
	public Long updater;

	@ApiModelProperty(value = "更新时间")
	public Date updateTime;

	@TableField(exist = false)
	@ApiModelProperty(value = "角色ids")
	@NotBlank(groups = {SysUserSaveGroup.class, SysUserUpdateGroup.class}, message = "用户角色不能为空")
	public String roleIds;

	@TableField(exist = false)
	@ApiModelProperty(value = "角色id")
	public List<Long> roleIdList;

}
